<template>
	<div class="">
		<header class="top_bar">
			<a onclick="window.history.go(-1)" class="icon_back"></a>
			<h3 class="cartname">新建地址</h3>
			<a href="javascript:void(0)" class="icon_menu"></a>
		</header>
		<section class="padding_top45 font_size14 background_fff">
			<div class="line_height60 padding_lf6_rg6 border_bot_dcdcdc">
				<label for="">收货人：</label>
				<input v-model="ReceiverName" type="text" />
			</div>
			<div class="line_height60 padding_lf6_rg6 border_bot_dcdcdc">
				<label for="">联系方式：</label>
				<input v-model="ReceiverPhone" type="text" />
			</div>
			<div class="line_height60 padding_lf6_rg6 border_bot_dcdcdc">
				<!--<label for="">所在地区：</label>-->
				<v-distpicker @selected="onSelected" @province="selectedProvince" @city="selectedCity" :province="province" :city="city" :area="area"></v-distpicker>

			</div>
			<div class="line_height60 padding_lf6_rg6 border_bot_dcdcdc">
				<label for="">详细地址：</label>
				<input v-model="AddrDetail" type="text" placeholder="街道、楼牌号等" />
			</div>
		</section>
		<div @click="addAddressSubmit" class="btn_bot">
			保存
		</div>
	</div>
</template>
<script>
	import { Toast } from 'mint-ui';
	import VDistpicker from 'v-distpicker'
	export default {
		components: {
			VDistpicker,
		},
		data() {
			return {
				addressList: [],
				popupVisibleAddAdr: false,
				ReceiverPhone: '',
				ReceiverName: '',
				province: '',
				city: '',
				area: '',
				AddrDetail: '',
			}
		},
		mounted() {
			//			this.getUDatas();
		},
		methods: {
			addAddressSubmit() {
				let _this = this;
				var postData = {
					ReceiverPhone: _this.ReceiverPhone,
					ReceiverName: _this.ReceiverName,
					AddrProvince: _this.province,
					AddrCity: _this.city,
					AddrArea: _this.area,
					AddrDetail: _this.AddrDetail,
				};
				console.log('postData', postData)
				_this.$http.post('/client/Address', postData, localStorage.Authorization, res => {
					console.log('地址getres', res)
					if(res.code === 200) {
						Toast(res.data);
						setTimeout(function(){
							_this.$router.go(-1)
						}, 1500)
					}
				})
			},
			onSelected(data) {
				this.province = data.province.value
				this.city = data.city.value
				this.area = data.area.value
			},
			selectedProvince(data) {
				this.province = data.value
			},
			selectedCity(data) {
				this.city = data.value
			}
		}
	}
</script>